﻿using InvoiceInvoker.Logic.Repositories;

namespace InvoiceInvoker.Logic
{
	public partial class RegisteredSeller
	{
		public Seller ToSeller()
		{
			Seller result = new Seller();
			result.SellerName = this.FirstName + " " + this.LastName;
			result.CompanyName = this.CompanyName;
			result.Street = this.Street;
			result.City = this.City;
			result.PostalCode = this.PostalCode;
			result.Nip = this.Nip;
			result.BankAccountNumber = this.BankAccountNumber;
			result.BankName = this.BankName;
			result.BankSwift = this.BankSwift;

			return result;
		}

		public void UpdateLastInvoiceNumber(string lastInvoiceNumber)
		{
			RegisteredSeller seller = new RegisteredSeller();
			seller.BankAccountNumber = BankAccountNumber;
			seller.BankName = BankName;
			seller.BankSwift = BankSwift;
			seller.City = City;
			seller.CompanyName = CompanyName;
			seller.FirstName = FirstName;
			seller.Id = Id;
			seller.InvoiceNumberFormat = InvoiceNumberFormat;
			seller.LastName = LastName;
			seller.Nip = Nip;
			seller.PostalCode = PostalCode;
			seller.Regon = Regon;
			seller.Street = Street;
			seller.UserName = UserName;

			seller.LastInvoiceNumber = lastInvoiceNumber;

			new RegisteredSellerRepository().Update(seller);
		}
	}
}
